package com.tianqu.tms.www.transfer.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Car;
import com.tianqu.tms.entity.Codes;
import com.tianqu.tms.entity.TransferAcceptedInfo;
import com.tianqu.tms.entity.TransferPersonalCarInfo;
import com.tianqu.tms.www.transfer.viewhelper.TransferRgInputViewHelper;

public class TransferRgInputTopAction extends TmsAction {
	private Logger logger = Logger.getLogger(TransferRgInputTopAction.class);

	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response, UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		// 需要加一些list
		TransferRgInputViewHelper view = (TransferRgInputViewHelper) uc.getAttribute(TmsConstants.VIEWHELP);

		Codes code = Codes.getInstance();
		// 构建下拉列表
		view.setCarTypeList(code.getCodeslistByItemId(Codes.VEHICLE_TYPE));// 车辆类型
		view.setColorList(code.getCodeslistByItemId(Codes.VEHICLE_COLOR));// 车辆颜色
		view.setCarUseList(code.getCodeslistByItemId(Codes.USER_NATURE));// 使用性质list
		view.setCardTypeList(code.getCodeslistByItemId(Codes.PLATE_TYPE));// 号牌种类list
		view.setCountryStyleList(code.getCodeslistByItemId(Codes.VEHICLE_COUNTRY));// 国别list
		view.setAttributeList(code.getCodeslistByItemId(Codes.ATTACHMENT_PROPERTY));// 车辆状态list'
		view.setOwnerTypeList(code.getCodeslistByItemId(Codes.CAR_OWNER));// 车主类型list
		view.setGainTypeList(code.getCodeslistByItemId(Codes.GAIN_TYPE));
		// 车辆来源
		view.setSourceList(code.getCodeslistByItemId(Codes.SOURCE_TYPE));
		TransferAcceptedInfo accept = new TransferAcceptedInfo();
		accept = accept.getAcceptInfoBySerial(view.getSerial(), "");
	
		if(accept!=null) {
			if (accept.getTransferType() == 2) {
				view.setTransferType3("√");
			}
			if (accept.getTransferType() == 3) {
				view.setTransferType5("√");
			}
			
			if ("1".equals(accept.getCarUse())) {
				view.setCarUse1("√");
			}
			if ("2".equals(accept.getCarUse())) {
				view.setCarUse19("√");
			}
			if ("3".equals(accept.getCarUse())) {
				view.setCarUse17("√");
			}
			if ("4".equals(accept.getCarUse())) {
				view.setCarUse14("√");
			}
			if ("5".equals(accept.getCarUse())) {
				view.setCarUse15("√");
			}
			if ("6".equals(accept.getCarUse())) {
				view.setCarUse16("√");
			}
			if ("7".equals(accept.getCarUse())) {
				view.setCarUse8("√");
			}
			if ("8".equals(accept.getCarUse())) {
				view.setCarUse9("√");
			}
			if ("9".equals(accept.getCarUse())) {
				view.setCarUse10("√");
			}
			if ("10".equals(accept.getCarUse())) {
				view.setCarUse18("√");
			}
			if ("11".equals(accept.getCarUse())) {
				view.setCarUse2("√");
			}
			if ("12".equals(accept.getCarUse())) {
				view.setCarUse3("√");
			}
			if ("13".equals(accept.getCarUse())) {
				view.setCarUse4("√");
			}
			if ("14".equals(accept.getCarUse())) {
				view.setCarUse5("√");
			}
			if ("15".equals(accept.getCarUse())) {
				view.setCarUse6("√");
			}
			if ("16".equals(accept.getCarUse())) {
				view.setCarUse7("√");
			}
			if ("17".equals(accept.getCarUse())) {
				view.setCarUse13("√");
			}
			if ("18".equals(accept.getCarUse())) {
				view.setCarUse12("√");
			}
			if ("19".equals(accept.getCarUse())) {
				view.setCarUse11("√");
			}
			if ("20".equals(accept.getCarUse())) {
				view.setCarUse20("√");
			}
			if ("21".equals(accept.getCarUse())) {
				view.setCarUse21("√");
			}
		}

		request.setAttribute(TmsConstants.VIEWHELP, view);
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}
}
